<?php
declare(strict_types=1);

namespace Dreamcat\ApiDoc\Enums;


use JetBrains\PhpStorm\Pure;
use MyCLabs\Enum\Enum;

/**
 * 数据类型
 * @author vijay
 * @method static DataType ENUM()
 * @method static DataType OBJECT()
 * @method static DataType MAP()
 * @method static DataType INTEGER()
 * @method static DataType STRING()
 * @method static DataType FLOAT()
 * @method static DataType BOOL()
 * @method static DataType NULL()
 * @method static DataType ARRAY()
 * @method static DataType UNKNOWN()
 */
class DataType extends Enum
{
    /** @var string 枚举 */
    public const ENUM = "enum";
    /** @var string 对象 */
    public const OBJECT = "object";
    /** @var string map */
    public const MAP = "map";
    /** @var string 整数 */
    public const INTEGER = "int";
    /** @var string 字符串 */
    public const STRING = "string";
    /** @var string 浮点数 */
    public const FLOAT = "float";
    /** @var string 布尔类型 */
    public const BOOL = "bool";
    /** @var string 数组 */
    public const ARRAY = "array";
    /** @var string NULL */
    public const NULL = "null";
    /** @var string 未知 */
    public const UNKNOWN = "unknown";

    private static array $scalaMap = [
        self::ENUM => true,
        self::INTEGER => true,
        self::STRING => true,
        self::FLOAT => true,
        self::BOOL => true,
    ];

    /**
     * 判断是否标量
     * @return bool
     * @noinspection PhpPureFunctionMayProduceSideEffectsInspection
     */
    #[Pure]
    public function isScala(): bool
    {
        return isset(self::$scalaMap[$this->getValue()]);
    }
}

# end of file
